<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/**
 * @var $block \Magento\CheckoutAgreements\Block\Agreements
 */
?>
<?php if (!$block->getAgreements()) {
    return;
} ?>
<ol id="checkout-agreements" class="agreements checkout items">
    <?php /** @var \Magento\CheckoutAgreements\Api\Data\AgreementInterface $agreement */ ?>
    <?php foreach ($block->getAgreements() as $agreement): ?>
        <li class="item">
            <div class="checkout-agreement-item-content"<?php echo($agreement->getContentHeight() ? ' style="height:' . $agreement->getContentHeight() . '"' : '')?>>
                <?php if ($agreement->getIsHtml()):?>
                    <?php /* @escapeNotVerified */ echo $agreement->getContent() ?>
                <?php else:?>
                    <?php echo nl2br($block->escapeHtml($agreement->getContent())) ?>
                <?php endif; ?>
            </div>
            <form id="checkout-agreements-form-<?php /* @escapeNotVerified */ echo $agreement->getAgreementId()?>" class="field choice agree required">
                <?php if($agreement->getMode() == \Magento\CheckoutAgreements\Model\AgreementModeOptions::MODE_MANUAL): ?>
                <input type="checkbox"
                       id="agreement-<?php /* @escapeNotVerified */ echo $agreement->getAgreementId()?>"
                       name="agreement[<?php /* @escapeNotVerified */ echo $agreement->getAgreementId()?>]"
                       value="1"
                       title="<?php echo $block->escapeHtml($agreement->getCheckboxText()) ?>"
                       class="checkbox"
                       data-validate="{required:true}"/>
                <label class="label" for="agreement-<?php /* @escapeNotVerified */ echo $agreement->getAgreementId()?>">
                    <span><?php echo $agreement->getIsHtml() ? $agreement->getCheckboxText() : $block->escapeHtml($agreement->getCheckboxText()) ?></span>
                </label>
                <?php elseif($agreement->getMode() == \Magento\CheckoutAgreements\Model\AgreementModeOptions::MODE_AUTO): ?>
                <div id="checkout-agreements-form-<?php /* @escapeNotVerified */ echo $agreement->getAgreementId()?>" class="field choice agree">
                    <span><?php echo $agreement->getIsHtml() ? $agreement->getCheckboxText() : $block->escapeHtml($agreement->getCheckboxText()) ?></span>
                </div>
                <?php endif; ?>
            </form>
        </li>
    <?php endforeach ?>
</ol>
